<template>
  <el-dialog
    title="订单编号列表"
    :visible.sync="orderNoDialogFlag"
    width="30%"
    :close-on-click-modal="false"
    :before-close="handleClose"
    center
  >
    <div class="order-list">
      <div
        class="order-item"
        v-for="item in orderList"
        :key="item.orderNo"
        @click="handleViewOrder(item.orderNo)"
      >
        {{ item.orderNo }}
      </div>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'orderNumberDialog',
  props: {
    orderNoDialogFlag: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      orderList: []
    }
  },
  methods: {
    //初始化数据
    initData(data) {
      this.orderList = data
    },
    //跳转订单详情
    handleViewOrder(orderNo) {
      this.$router.push({ name: 'OrderDetail', query: { orderNo } })
    },
    handleClose() {
      this.$emit('update:orderNoDialogFlag', false)
    }
  }
}
</script>

<style lang="scss" scoped>
.order-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  .order-item {
    cursor: pointer;
    color: #1989fa;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    text-decoration: underline;
  }
}
</style>
